<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>变量的解构赋值</title>
</head>

<body>
    <script>
        //ES6 
        // 解构赋值：按照解构进行赋值
        // 数组解构
        // let arr = ['冰火魔厨','斗罗大陆','斗破苍穹',['方想','唐家三少']];
        // let a = arr[0];
        // let b = arr[1];
        // let c = arr[2];
        // console.log(a, b, c);

        // let [a1,b1,c1,[d1,e1]] = arr;

        // console.log(a1,b1,c1,d1,e1);

        // 对象解构,对象是无序的，所以解构的时候，按照属性名解构
        let obj = {
            age:18,
            hobby:'台球',
            name:'atguigu'
        }

        // let {name,age,hobby} = obj;
        // console.log(name,age,hobby);

        // let {age} = obj;
        // console.log(age);

        // 混合解构
        // let eason = {
        //     name:'陈奕迅',
        //     age:48,
        //     songs:[
        //         '爱情转移',
        //         '兄妹',
        //         '一个人失眠',
        //         '孤勇者'
        //     ]
        // }
        // let { age, name,songs:[ai,xiong,yi,gu]} = eason;
        // console.log(age,name,ai,xiong,yi,gu);

        // 解构的默认值,惰性
        function fn(){
            console.log(123);
        }

        let arr = [];

        let [a=fn()] = arr;
        console.log(a);

    </script>
</body>

</html>